<template>
  <div>
    <!-- 商品详情 -->
    <div>
        <p>书名：{{book.name}}</p>
        <p>作者：{{book.author}}</p>
    </div>
    <hr/>
    <!-- 评论 -->
    <ul>
        <li v-for="item in comments" :key="item.id">
            <p>评论内容：{{item.content}}</p>
            <p>评论时间：{{item.time}}</p>
            <p>评论人：{{item.username}}</p>
        </li> 
    </ul>
  </div>    
</template>

<script>

export default {
    name:"GoodsDetail",
    data(){
        return {
            book:{},
            comments:[]
        }
    },
    created(){
        // console.log("this.$route.params.proid",this.$route.params.proid);

       

        const getComments=()=>{
            return this.$http.get("/comments",{
                params:{
                    bookid:"878911"
                }
            })
        }

        this.$http.all([getGoodsList(),getComments()])
        .then(this.$http.spread((bookRes,commentsRes)=>{
            console.log("bookRes",bookRes);
            this.book = bookRes.data[0];
            console.log("commentsRes",commentsRes);
            this.comments = commentsRes.data;
        }))
        .catch(err=>{
            console.log("出错了err",err);
        })
    }

}
</script>

<style>

</style>